 {{include file="../tools/jquery_validator2.htm"}}
 {{include file="../tools/upload.htm"}}
  {{include file="../tools/inputtag.htm"}}
  {{include file="../tools/editableSelect.htm"}} 
  <script>
 $(function(){
	 $('.makeEditable').editableSelect().change(function(){
		 	
		
      });
	$('.tags_input').tagsInput({width:'auto',defaultText:'输入后按回车'});
  })
 </script>
  <div class="userbox">
  <h2>产品编辑</h2>
  <form name="category" id="category" method="post">
      <div class="left userstore" style="background:none">
      <table class="width65">
          <tr>
          <td colspan="3" class="nameorange" >请描述产品信息</td>
        </tr>
          <tr>
          <td title="就是案例的名字，能吸引人就好" class="td1" >案&nbsp;&nbsp;例&nbsp;&nbsp;名</td>
          <td><input type="text" name="goods_name" value="{{$goods.goods_name}}" /></td>
        </tr>
          <tr class="hide">
          <td title="服务？营销？运营？主要是为了方便日后整理。" class="td1">案例类别</td>
          <td><select class="makeEditable" name="goods_sn">
              
          {{if $goods.goods_sn}}
              <option>{{$goods.goods_sn}}</option>
              {{/if}}
            
              <option value="0">smart案例</option>
              <option value="1">smart品牌</option>
              <option value="2">smart模式</option>
              <option value="3">smart推广</option>
            </select>
          </tr>
          <tr>
          <td title="最能体现方案特点的词，方便买家找到你。" class="td1">关&nbsp;&nbsp;键&nbsp;&nbsp;字</td>
          <td>
          
   
     {{$kwd_def = preg_split("/,/",$goods.keywords)}}
    
	 {{foreach from=$kwd item=list key=key}}
     <div class="tabdiv">
     {{foreach from=$list key=k item=l}}
      {{$l.keyword}} <input type="checkbox" name="keywords[]" value="{{$l.keyword}}" {{if in_array({{$l.keyword}},$kwd_def)}}checked="checked"{{/if}}/> &nbsp;
      {{/foreach}}
      </div>
     {{/foreach}}
   
	 如果以上这些还不过瘾  &nbsp;&nbsp;<input type="checkbox" value="" onclick="toggleTag($(this))" {{if count($diff)}} checked="checked"{{/if}}/>
    
          
          <input type="text" name="keywords7" class="tags_input" value="{{$goods.keywords}}" style="width:60px;"/></td>
        </tr>
          <tr>
          <td title="从方案变成生产力需要花费的RMB，如果还没有投产就估计一个吧。单位是元。" class="td1">投产成本</td>
          <td><input type="text" name="market_price" value="{{$goods.market_price}}" style="width:100px"/>
              元</td>
        </tr>
        <tr class="md">
          <td title="你的产品包括以下内容" class="td1">产品卖点</td>
          {{$md_def = preg_split("/,/",$goods.descs)}}
       

    {{$md=array('流程优化','营销技巧','活动方案','宣传海报','营销话术','心得技巧','现场照片','分析数据','实用工具','创意布局','台账日志','小店特色','微信文案','创新思路','品牌推广','产品超市','风险合规','设备维护','物料杂项','精益模式','服务规范','形象礼仪','案例分享')}}
          <td>
      {{foreach from=$md item=list key=key}}
      {{$key=$key+1}}
       {{$list}} <input type="checkbox" name="descs[]" value="{{$list}}" {{if in_array({{$list}},$md_def)}} checked="checked"{{/if}}/> &nbsp;
          {{if $key%4==0 }}
           <br />
          {{/if}}
         {{/foreach}}
          {{$diff=array()}}
         {{foreach $md_def item=list key=key}}
          {{if !in_array($list,$md) && $list}}
           {{$diff[]=$list}}
          {{/if}}
         {{/foreach}}
      		<br />
         如果以上这些还不过瘾  &nbsp;&nbsp;<input type="checkbox"  value="" onclick="toggleTag($(this))" {{if count($diff)}} checked="checked"{{/if}}/>
          
         <input type="text" name="descs7" class="tags_input"  style="width:60px;" value="{{join(",",$diff)}}"/>
          </td>
        </tr>
          <tr>
          <td title="方案卖不卖的掉就全靠它了！不过你也得卖卖关子，核心内容还得让人掏腰包才行。" class="td1">简要描述</td>
          <td><textarea style="height:100px;" name="goods_desc" onclick='if(this.value=="（字数不要超过80字）用一段最具概括性的话语来描述你的产品，最好卖卖关子，核心内容一定要别人掏钱才能看到哟~")this.value=""'>{{$goods.goods_desc|default:"（字数不要超过80字）用一段最具概括性的话语来描述你的产品，最好卖卖关子，核心内容一定要别人掏钱才能看到哟~"}}</textarea></td>
        </tr>
          <tr>
          <td title="用来吸引客户的，能与方案相关最好。" class="td1">案例图片</td>
          <td>
        {{if $goods.gallery}}
        {{foreach from=$goods.gallery item=list key=key}}
        {{if $list.img==$goods.img}}
        	{{$list.img=$list.img|cat:"?ori=true"}}
        {{/if}}
        {{$default[$key]['url']=$list.img}}
        {{$default[$key]['file_name']=$list.title}}
        {{$default[$key]['type']='jpg'}}
        {{/foreach}}
        {{$default=json_encode($default)}}
        <div id="gallery_default" class="none">{{$default}}</div>
       {{/if}}
           <div id="gallery"> </div>
          <div id="gallery_res">
       
          </div>
          <input type="hidden" value="{{foreach from=$goods.gallery item=list key=key}}{{$list.img}},{{/foreach}}" name="gallery" id="gallerys"/>
            </td>
        </tr>
          <tr>
          <td title="核心内容，不解释。" class="td1">完整案例</td>
          <td > 
          
         
       {{if $goods.goods_brief}}
        {{$default=json_encode($goods.goods_briefs)}}
        <div id="goods_brief_default" class="none">{{$default}}</div>
       {{/if}}
           <div id="goods_brief"> </div>
          <div id="goods_brief_res">
       
          </div>
          <input type="hidden" value=" {{foreach from=$goods.goods_briefs item=list key=key}}{{$list.url}},{{/foreach}}" name="goods_brief" id="goods_briefs"/></td>
        </tr>
          <tr>
          <td title="你认为你的产品值多少？" class="td1">售&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价</td>
          <td> {{if $c_id==$smarty.const.JF_MALL_ID}}
              {{$price=array_fill(1,1000,'')}}
              {{else}}
              {{$price=array_fill(1,10,'')}}
              {{/if}}
              <select name="shop_price">
              <option value="">请选择售价</option>
              
         {{foreach from=$price item=list key=key}}
         
         
              <option value='{{$key}}' {{if intval($goods.shop_price)==$key}} selected="selected"{{/if}}>{{$key}}</option>
              
         
		 {{/foreach}}
          
            </select>
          </tr>
        </table>
      <div class="icobtn">
          <input type="hidden"  name="goods_id" value="{{$goods.goods_id}}"/>
          <input type="hidden"  name="cat_id" value="{{$c_id}}"/>
          <input class="next" type="button"  onclick="steps()"/>
        </div>
    </div>
    </form>
  {{include file="./../user/user_act_right.htm"}} 
  <!--right end--> 
  
</div>
{{if !$diff}}
  <script>
  	$(function(){
		 $(".md").find(".tagsinput").hide();
	})
  </script>
{{/if}}
  <script>
  function toggleTag(obj){
	 obj.parent("td").find(".tagsinput").toggle();
  }
  $(function(){
	  
	
		var swf1 = swfUpload({
					   size:10,
					   limit:10,
					   type:'*.jpg;*.png;*.gif',
					   button_id:'gallery',
					
					   
					   index:0,   //第几个实例
					   set_input:true, //是否将文件信息写到input中（json）
					   data_type:'text'
				   });
		var swf2 = swfUpload({
					   size:10,
					   limit:10,
					   type:'*.*',
					   button_id:'goods_brief',
					   index:1,   //第几个实例
					   set_input:true, //是否将文件信息写到input中（json）
					   data_type:'json'
				   });
	jQuery.validator.addMethod("goodsDesc", function(value, element) {  
		var def = '（字数不要超过80字）用一段最具概括性的话语来描述你的产品，最好卖卖关子，核心内容一定要别人掏钱才能看到哟~'; 
		
	   if(value==def) 
	   {
		    $("textarea[name=goods_desc]").val('');
			return false;   
	   }   
	 	return true;      
	 }, "该项必须填写");	
		
	 $('#category').validate(
	  {
	   
	
	   rules: {
		goods_name: {
		  minlength: 2,
		  maxlength:60,
		  required: true
		
		},
		goods_sn: {
		  minlength: 2,
		  maxlength:10,
		  required: true
		
		},
		keywords: {
		  required: true
		 
		
		},
		market_price: {
		  required: true,
		  number:true
		},
		shop_price: {
		  required: true,
		  number:true
		},
		goods_desc: {
		  goodsDesc:true,
		  maxlength:80
		
		},
		img: {
		  minlength: 2,
		  required: true
		
		},
		gallery: {
		  minlength: 2,
		  required: true
		
		}
	  },
	
	  messages: {   
		  
		  
		img:{   
			   required: "请上方案！" 
		 },
		   
		gallery:{   
			   required: "请上方案图片！" 
		 },
		 market_price: {
		  
		  number:'请输入数字'
		}
   		}
	 });
		 
  })
  
  function steps(idx){
	  var keywords = $("input[name=keywords]").val();
	  if(!keywords)
	  {
		//alert("至少输入一个关键词!")
		//return false;  
	  }
	  if( $('#category').valid())
	  {
	   	$('#category').submit();
	  }
  }
 
  </script>